<%@language=vbscript%>
<%
	'Session("bChucnang")=4
	Session("FormName")="F20"
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file="..\RootContent.inc"-->
<!--#include file=..\getFormName.inc-->
<!--#include file="Nhap_VTdi\NhapNhanh_NN.inc"-->
<!--#include file="Nhap_VTdi\NhapNhanh_NK.inc"-->
<!--#include file="Nhap_VTdi\NhapNhanh_DV.inc"-->
<!--#include file="Nhap_VTdi\NhapNhanh_SKH.inc"-->
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>VĂN THƯ ĐI</title>
</head>
<%
'HienSX
	sort=Request("sort")
	chuyendi=request("chuyendi")
	backform=request("backform")+1
	bDangky=Request("bDangky")
	Dim Msg
	bComm=Request("bComm")
	maflow=request("maflow")
	if bComm="edit" then
		bID=Request("TxtID")
		sSQL="Select * from VTDi Where ID Like '"& bID &"'"
		Set RecT=Server.CreateObject("ADODB.Recordset")
		RecT.CursorType=3
		RecT.CacheSize=5
		RecT.Open sSQL,Conn
		Dim bDisplay
		bDisplay=False
		if RecT.RecordCount>0 then
			dim bSoghinhan
			Dim bID
			Dim bSogoccu
			Session("bMaVBDi")=RecT("ID")	
			Session("bTenVBDi")=RecT("Trichyeu")		
			bSoghinhan=trim(RecT("soghinhan"))
			bOutNum=cstr(RecT("so"))
			bOutnumcu=bOutNum
			bOutSymbol=right(bSoghinhan,len(bSoghinhan)-len(bOutNum)-1)
			bIDcu=RecT("ID")
			bSoghinhancu=RecT("soghinhan")			
			bTrichyeu=trim(RecT("Trichyeu"))
			bTomtat=trim(RecT("Tomtat"))
			bTinhchat=trim(RecT("Tinhchat"))
			bTinhchat1=trim(RecT("Tinhchat1"))
			bTentep=trim(RecT("Tentep"))
			bTentepcu=trim(RecT("Tentep"))
			bNguoiky=trim(RecT("Nguoiky"))
			bNgayky=trim(RecT("Ngayky"))
			bNgaydi=trim(RecT("Ngaydi"))
			bNam=year(RecT("Ngaydi"))
			bNamcu=year(RecT("Ngaydi"))
			bNguoinhan=trim(RecT("Nguoinhan"))
			bTukhoa=trim(RecT("Tukhoa"))
			bReadwrite=RecT("congcong")
			bCongcong=RecT("congcong")
			bTTDuyet=RecT("trangthaiduyet")
			bDiachiluutru=RecT("diachiluutru")
			bPhanloai=RecT("PhanLoai")
			bPhanloaicu=RecT("Phanloai")
			bSoban=RecT("Soban")
			bSoto=RecT("Soto")
			bSLNoidung=RecT("Soluongnoidung")
			bNoinhan=RecT("Noinhan")
			bDisplay=true
			bBaocao=RecT("Baocao")
			bSelect1=RecT("DVSoan")
			bSelect2=RecT("Noinhan")
		end if
	end if
	Dim bTonTai
	Select case bComm
		case "okedit"
			bghinhan=Request("bghinhan")
			if bghinhan then
				bOutNum=Request("TxtOutNum")			
				bOutSymbol=Request("TxtOutSymbol")
				bTrichyeu=Request("TxtTrichyeu")
				bTomtat=Request("TxtTomtat")
				bTinhchat=Request("ComboTinhchat")
				bTinhchat1=Request("ComboTinhchat")
				bTentep=Request("TxtTentep")
				bNguoiky=trim(Request("TxtNguoiky"))
				bNgayky=request("TxtNgayky")
				bNgaydi=bNgayky
				bNam=year(bNgaydi)
				bNguoinhan=Request("TxtNguoinhan")
				bTukhoa=Request("TxtTukhoa")
				bReadwrite=Request("bReadwrite")
				bNoinhan=Request("TxtNoinhan")
				bSelect1=Request("Select1")
				bSelect2=Request("Select2")
				bBaocao=Request("ChkBC")
				bDiachiluuTru=Request("TxtDiachiluutru")
				bCongcong=Request("Congcong")
				bSLNoidung=Request("TxtSLNoidung")
				bSoban=Request("TxtSoban")
				bSoto=Request("TxtSoto")
				bPhanloai=Request("CboOutSymbol")
			else
				bOutnum=Request("bOutnum")			
				bOutSymbol=Request("bOutSymbol")
				bTrichyeu=Request("bTrichyeu")
				bTomtat=trim(Request("bTomtat"))
				bTinhchat=Request("bTinhchat")
				bTinhchat1=Request("bTinhchat1")
				bTentep=Request("bTentep")
				bNguoiky=trim(Request("bNguoiky"))
				bNGayky=SaveDate(request("bNGayky"))
				bNGaydi=SaveDate(request("bNGaydi"))
				bNam=request("bNam")
				bNguoinhan=Request("bNguoinhan")
				bTukhoa=Request("bTukhoa")
				bReadwrite=Request("bReadwrite")
				bnoinhan=Request("bnoinhan")
				bSelect1=Request("bSelect1")
				bSelect2=Request("bSelect2")
				bBaocao=Request("bBaocao")
				bDiachiluuTru=Request("bDiachiluuTru")
				bCongcong=Request("bCongcong")
				bSLNoidung=Request("bSLNoidung")
				bSoban=Request("bSoban")
				bSoto=Request("bSoto")
				bPhanloai=Request("bPhanloai")
			end if
			if bReadwrite then
				bReadwrite=1
			else
				bReadwrite=0
			end if
			
			if bCongcong then
				bCongcong=1
			else
				bCongcong=0
			end if
			'bBaocao=Request("ChkBC")
			if bBaocao then
				bBaocao=1
			else
				bBaocao=0
			end if
			bSoghinhancu=Request("bSoghinhancu")
			bIDcu=Request("bIDcu")
			bNamcu=request("bNamcu")
			bOutNumcu=request("bOutNumcu")
			bPhanloaicu=request("bPhanloaicu")
			

			
			bTTDuyet=Request("bTTDuyet")

			if bTTDuyet then
				bTTDuyet=1
			else
				bTTDuyet=0
			end if
			
			if Request("filename")<>"" then
				bTentepcu=Request("filename")
			end if
			bSoghinhan=trim(bOutnum)+"/"+trim(bOutSymbol)
			bNguoiduyet=Session("bMaCB")
			bNgayky=SaveDate(bNgayky)
			bNgaydi=SaveDate(bNgaydi)
			'bg thphuc 27-02-03
			'kiem tra ten nhom co ton tai khong
			bdvxl=Donvixuly(bSelect1)
			intloi=instr(1,bdvxl,"#")
			if intloi > 0 then
				bdonvixuly=mid(bdvxl,1,intloi-1)
				'Msg="Đơn vị "+mid(bdvxl,intloi+1,len(bdvxl)-intloi)+" không tồn tại"
			else
				bdonvixuly=bdvxl
			end if
			'ed thphuc 27-02-03
			On Error resume next
			Conn.BeginTrans
			if (trim(CSTR(bSoghinhan))=trim(CSTR(bSoghinhancu)))  and (trim(CSTR(bNamcu))=trim(CSTR(bnam))) and (bPhanloaicu=bPhanloai) then
				bID="DI"+cstr(bNam)+"_"+cstr(bPhanloai)+"_"+cstr(bOutnum)+"_" +cstr(bOutSymbol)
'Hien 21_05
				bTentep=replace(bID,"/","_")+".VT"
				sSQL="Update VTdi set ID='"& bID _
				&"', Ngaydi='"& bNgaydi &"', Ngayky='"& bNgayky _
					&"',Nguoiky='"& ModiString(bNguoiky) _
					&"',Tomtat='"& ModiString(trim(bTomtat)) &"',Trichyeu='"& ModiString(bTrichyeu) &"',Tukhoa='"& ModiString(bTukhoa) _
					&"',Nguoinhan='"& ModiString(bNguoinhan) _
					&"',Tinhchat='"& ModiString(bTinhchat) _
					&"',PhanLoai="& bPhanloai _
					&",Tentep='"& ModiString(bTentep) _
					&"',Soban='"& ModiString(bSoban) _
					&"',Soto='"& ModiString(bSoto) _
					&"',Diachiluutru="& bDiachiluutru _
					&",Congcong="& bReadwrite _
					&",Trangthaiduyet="& bTTDuyet _
					&",Nguoiduyet='"& bNguoiduyet _
					&"',Noinhan='"& bSelect2 _
					&"',DVSoan='"& bSelect1 _
					&"',donvixuly='"& bdonvixuly _
					&"',Baocao="& bBaocao _
					&" Where ID ='"& bIDcu &"'" 
				Conn.Execute sSQL
				'Msg="Nội dung đã được sửa"
				bComm="edit"
			end if
			if (trim(cstr(bSoghinhan))<>trim(cstr(bSoghinhancu))) and (trim(bNamcu)=trim(bNam)) and (bPhanloaicu=bPhanloai) then

				if KTSoghinhan(bSoghinhan,bPhanloai,bNam,"okedit") then
					bID="DI"+cstr(bNam)+"_"+cstr(bPhanloai)+"_"+cstr(bOutnum)+"_" +cstr(bOutSymbol)
'Hien 21_05
					bTentep=replace(bID,"/","_")+".VT"
					bTonTai=false
					bComm="edit"
				else
					Msg="Số, ký hiệu đã tồn tại"
					bTontai=True
					bDisplay=true
					bComm="edit"
					bIDcu=request("bIDcu")
					bNamcu=request("bNamcu")
					bPhanloaicu=request("bPhanloaicu")
					bOutnumcu=request("bOutnumcu")
					bSoghinhancu=request("bSoghinhancu")
					'bOutnum=bOutnumcu
					bID=bIDcu
				end if
				if not bTontai then
					'bg thphuc 27-02-03
					'kiem tra ten nhom co ton tai khong
					bdvxl=Donvixuly(bSelect1)
					intloi=instr(1,bdvxl,"#")
					if intloi > 0 then
						bdonvixuly=mid(bdvxl,1,intloi-1)
						'Msg="Đơn vị "+mid(bdvxl,intloi+1,len(bdvxl)-intloi)+" không tồn tại"
					else
						bdonvixuly=bdvxl
					end if
					'ed thphuc 27-02-03
					sSQL="Update VTDi set so="& bOutnum &" ,ID='"& ModiString(bID)&"',Soghinhan='"& ModiString(bSoghinhan) _
						&"', ngaydi='"& bNgaydi &"',ngayky='"& bNgayky _
						&"',Nguoiky='"& ModiString(bNguoiky) _
						&"',Tomtat='"& ModiString(trim(bTomtat)) &"',Trichyeu='"& ModiString(bTrichyeu) &"',Tukhoa='"& ModiString(bTukhoa) _
						&"',Nguoinhan='"& ModiString(bNguoinhan) _
						&"',Tinhchat='"& ModiString(bTinhchat) _
						&"',Soto='"& ModiString(bSoto) _
						&"',Soban='"& ModiString(bSoban) _
						&"',Phanloai="& bPhanloai _
						&",Tentep='"& ModiString(bTentep) _
						&"',Diachiluutru="& bDiachiluutru _
						&",Congcong="& bReadwrite _
						&",Trangthaiduyet="& bTTDuyet _
						&",Nguoiduyet='"& bNguoiduyet _
						&"',Noinhan='"& bSelect2 _
						&"',DVSoan='"& bSelect1 _
						&"',donvixuly='"& bdonvixuly _
						&"',Baocao="& bBaocao _
						&" Where ID ='"& bIDcu &"'" 
					Conn.Execute sSQL
					'Msg="Nội dung đã được sửa"
					bSoghinhancu=bSoghinhan
					bUpdate=true
				end if
			end if
			if  (trim(cstr(bNamcu))<>trim(cstr(bNam))) or (bPhanloaicu<>bPhanloai) then
				if KTSoghinhan(bSoghinhan,bPhanloai,bNam,"okedit") then
					bID="DI"+cstr(bNam)+"_"+cstr(bPhanloai)+"_"+cstr(bOutnum)+"_" +cstr(bOutSymbol)
'Hien 21_05
					bTentep=replace(bID,"/","_")+".VT"
					bTonTai=false
					bComm="edit"
				else
					Msg="Số, ký hiệu đã tồn tại"
					bTontai=True
					bDisplay=True
					bComm="edit"
					bIDcu=request("bIDcu")
					bNamcu=request("bNamcu")
					bPhanloaicu=request("bPhanloaicu")
					bOutnumcu=request("bOutnumcu")
					bSoghinhancu=request("bSoghinhancu")
'					bOutnum=bOutnumcu
					bID=bIDcu
				end if
				if not bTontai then
					'bg thphuc 27-02-03
					'kiem tra ten nhom co ton tai khong
					bdvxl=Donvixuly(bSelect1)
					intloi=instr(1,bdvxl,"#")
					if intloi > 0 then
						bdonvixuly=mid(bdvxl,1,intloi-1)
						'Msg="Đơn vị "+mid(bdvxl,intloi+1,len(bdvxl)-intloi)+" không tồn tại"
					else
						bdonvixuly=bdvxl
					end if
					'ed thphuc 27-02-03
					sSQL="Update VTDi set so="& bOutnum &" ,ID='"& ModiString(bID) &"',Soghinhan='"& ModiString(bSoghinhan) _
						&"',Ngaydi='"& bNgaydi &"',Ngayky='"& bNgayky _
						&"',Nguoiky='"& ModiString(bNguoiky) _
						&"',Tomtat='"& ModiString(trim(bTomtat)) _
						&"',Trichyeu='"& ModiString(bTrichyeu) &"',Tukhoa='"& ModiString(bTukhoa) _
						&"',Nguoinhan='"& ModiString(bNguoinhan) _
						&"',Tinhchat='"& ModiString(bTinhchat) _
						&"',soban='"& ModiString(bSoban) _
						&"',Soto='"& ModiString(bSoto) _
						&"',Phanloai="& bPhanloai _
						&",Tentep='"& ModiString(bTentep) _
						&"',diachiluutru="& bDiachiluutru _
						&",Congcong="& bReadwrite _
						&",trangthaiduyet="& bTTDuyet _
						&",Nguoiduyet='"& bNguoiduyet _
						&"',noinhan='"& bSelect2 _
						&"',DVSoan='"& bSelect1 _
						&"',donvixuly='"& bdonvixuly _
						&"',Baocao="& bBaocao _
						&" Where ID ='"& bIDcu &"'" 
						Conn.Execute sSQL
					'Msg="Nội dung đã được sửa"
					bComm="edit"
					bUpdate=true
				end if
			end if
			%><%=Err.description%><%
			Conn.Execute sSQL
			if bUpdate then
				sSQL="Update Muontra set BophanQL="& bDiachiluutru &",matailieu = '"& ModiString(bID) &"' where matailieu like '"& bIDcu &"' and Loaitailieu=2"
				Conn.Execute sSQL 
'Hien 21_05
				sSQL="Update vanban_noidung set mavanthu='"& ModiString(bID) &"' where mavanthu Like '"& bIDcu &"' and loaivanthu='2'"
				Conn.Execute sSQL

				sSQL="Update Quyen set mavanthu='"& ModiString(bID) &"' where mavanthu Like '"& bIDcu &"' and maloaivanthu='2'"
				Conn.Execute sSQL
				sSQL="Update Quyen_nhom set mavanthu='"& ModiString(bID) &"' where mavanthu Like '"& bIDcu &"' and maloaivanthu='2'"
				Conn.Execute sSQL				
				'Sua File
				set TextFile=server.CreateObject("Activefile.file")
'Hien 21_05
				PathOld=RootContent & "Upload\"& cstr(bNamcu) &"\Di\Text"
				PathOld=Pathold & "\" & replace(bIDcu,"/","_") & ".VT" 
				Path=RootContent & "Upload\"& cstr(bNam) &"\Di\Text"
				Path=Path & "\" & replace(bID,"/","_") & ".VT"
				'Tao thu muc nam moi
				Set bDir=server.CreateObject("ActiveFile.Directory")
		     	bPathFolder=RootContent & "Upload"& "\" & bNam
		          bDir.Path=bPathFolder
    				if not bDir.Exists() then
    				   	call bDir.Create(bPathFolder)
    				end if
	    			bPathFolder=bPathFolder & "\Di"
				bDir.Path=bPathFolder
	     		if not bDir.Exists() then
					Call bDir.Create(bPathFolder)
				end if
				bPathFolder=bPathFolder & "\Text"
			    	bDir.Path=bPathFolder
				if not bDir.Exists() then
	   				Call bDir.Create(bPathFolder)
				end if
			     Set bDir=nothing						
				TextFile.Name=Path
				if TextFile.Exists() then
					TextFile.Delete()
				end if				
				TextFile.Name=PathOld
				if TextFile.Exists() then
					Call TextFile.Copy (Path)
				end if
				TextFile.Name=PathOld		
				if TextFile.Exists() then
					TextFile.Delete()
				end if
				sSQL="Select * from vanban_noidung where mavanthu Like '"& ModiString(bID) &"' and Loaivanthu='2' order by Sothutu"			
				Set RecRename=server.CreateObject("ADODB.Recordset")
				RecRename.CursorType=3
				RecRename.CacheSize=5
				RecRename.Open sSQL,Conn
				Set Ex=server.CreateObject("Vinalines.ClsFile")
				Do while not RecRename.EOF					
					Pathold=RootContent & "Upload\"& Cstr(bNamcu) &"\Di"
					Pathold=Pathold & "\" & replace(bIDcu,"/","_") & "S" & trim(cstr(RecRename("sothutu"))) & "." & Ex.GetExtensionFile(RecRename("Tentep"))			
					Path=RootContent & "Upload\"& Cstr(bNam) &"\DI"
					Path=Path & "\" & replace(bID,"/","_") & "S" & trim(cstr(RecRename("sothutu"))) & "." & Ex.GetExtensionFile(RecRename("Tentep"))			
					TextFile.Name=Path
					if TextFile.Exists() then
						TextFile.delete()
					end if
					TextFile.Name=PathOld
					if TextFile.Exists() then
						call TextFile.Copy (Path)
						TextFile.Delete()
					end if
					bName=replace(bID,"/","_") & "S" & trim(cstr(RecRename("sothutu"))) & "." & Ex.GetExtensionFile(RecRename("Tentep"))
					sSQL="Update vanban_noidung set Tentep='"& bName &"' where loaivanthu='2' and  Sothutu="& RecRename("sothutu") &" And mavanthu like '"& ModiString(bID) &"'"
					Conn.Execute sSQL		
					RecRename.MoveNext
				Loop
				%><%=Err.Description%><%
				RecRename.Close
				set RecRename=nothing
				set TextFile=nothing
				set Ex=nothing
				if bReadwrite then
					sSQL="Delete Quyen where maloaivanthu='2' and mavanthu like '"& ModiString(bID) &"'"
					Conn.Execute sSQL
					sSQL="Delete Quyen_nhom where maloaivanthu='2' and mavanthu like '"& ModiString(bID) &"'"
					Conn.Execute sSQL
				end if
			End if
			'Ket Thuc Transaction
			if Err.number=0 then
				if Session("VanBan")="" then 
					Session("VanBan")="-" & Session("VanBan") & modistring(bID) & "-"
				else
					Session("VanBan")=Session("VanBan") & modistring(bID) & "-"
				end if
				Conn.CommitTrans
				btrangthai=1
			else
				Conn.RollbackTrans
				bTrangthai=0
			end if
			'Ghi nhan Ai da login thanh cong
			bHoten=Session("bHoten")
			bNgaygio=cstr(Date()) &" "& cstr(Time())
			bChucnang="C&#7853;p nh&#7853;t V&#259;n th&#432; quyết định"
			bIDTailieu=bSoghinhan
			bDongtac="S&#7917;a"
			sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
				&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"',"& bTrangthai &")"
			Conn.Execute sSQL	
			
			bIDcu=bID
			bNamcu=bNam
			bPhanloaicu=bPhanloai
			bOutnumcu=bOutnum
			Session("bMaVBQD")=bID
			Session("bTenVBQD")=bTrichyeu			
		case "okadd"
			bOutNum=Request("TxtOutNum")
			bOutSymbol=Request("TxtOutSymbol")
			bTrichyeu=Request("TxtTrichyeu")
			bTomtat=Request("TxtTomtat")
			bTinhchat=Request("ComboTinhchat")
			bTinhchat1=Request("ComboTinhchat")
			bSoban=Request("TxtSoban")
			bSoto=Request("TxtSoto")
			bTentep=Request("TxtTentep")
			bNguoiky=trim(Request("TxtNguoiky"))
			bNgayky=request("TxtNgayky")
			bNgaydi=bNgayky
			bNam=year(bNgaydi)
			bNoinhan=request("TxtNoinhan")
			bNguoinhan=Request("TxtNguoinhan")
			bTukhoa=Request("TxtTukhoa")
			bReadwrite=Request("bReadwrite")			
			bSelect1=Request("Select1")
			bSelect2=Request("Select2")
			if bReadwrite then
				bReadwrite=1
			else
				bReadwrite=0
			end if
			bCongcong=Request("congcong")
			if bCongcong then
				bCongcong=1
			else
				bCongcong=0
			end if
			bBaocao=Request("ChkBC")
			if bBaocao then	
				bBaocao=1
			else
				bBaocao=0
			end if
			bDiachiluutru=request("Txtdiachiluutru")
			bPhanloai=Request("CboOutSymbol")
			bTTDuyet=Request("bTTDuyet")
			if bTTDuyet then
				bTTDuyet=1
			else
				bTTDuyet=0
			end if
			bNoigui=Request("TxtNoigui")
			bSLNoidung=Request("TxtSLNoidung")

			bSoghinhan=trim(bOutnum) & "/" & trim(bOutSymbol)
			bID="DI"+cstr(year(bNgayky))+"_"+cstr(bPhanloai)+"_"+cstr(bOutnum)+ "_" +cstr(bOutSymbol)
'Hien 21_05
			bTentep=replace(bID,"/","_")+".VT"
			bNguoiduyet=Session("bMaCB")
			bNgayky=SaveDate(bNgayky)
			bNgaydi=SaveDate(bNgaydi)
			Session("defaultNgayKy")=bNgayky
			bNamcu=bNam
			bPhanloaicu=bPhanloai
			bOutnumcu=bOutnum

			if KTSoghinhan(bSoghinhan,bPhanloai,bNam,"okadd") then
				Msg="N&#7897;i dung c&#7853;p nh&#7853;t"
				bTonTai=false
				bComm="edit"
			else
				Msg="Số, ký hiệu đã tồn tại"
				bTonTai=true
				bComm="add"
			end if

			
			if not bTonTai then
				'Tao Transaction
				On Error resume next
				Conn.BeginTrans			
				'Loc so tu dong theo nam + Phan loai					
				'bg thphuc 27-02-03
				'kiem tra ten nhom co ton tai khong
				bdvxl=Donvixuly(bSelect1)
				intloi=instr(1,bdvxl,"#")
				if intloi > 0 then
					bdonvixuly=mid(bdvxl,1,intloi-1)
				else
					bdonvixuly=bdvxl
				end if
				'ed thphuc 27-02-03
				sSQL="Insert Into VTDi(ID,so,soghinhan,tomtat,trichyeu,tinhchat,tinhchat1,soto,soban,phanloai,tentep,nguoiky,ngaydi,ngayky,diachiluutru,nguoinhan,tukhoa,congcong, trangthaiduyet,nguoiduyet,loai,soluongnoidung,noinhan,DVSoan,baocao,donvixuly) values('"& modistring(bID) &"',"& bOutnum &",'"& modistring(bSoghinhan) _
						&"','"& ModiString(trim(bTomtat)) &"','"& ModiString(bTrichyeu) &"','"& ModiString(bTinhchat) &"','"& ModiString(bTinhchat1) _
						&"','"& ModiString(bSoto) &"','"& ModiString(bSoban) &"',"& bPhanloai _
						&",'"& ModiString(bTentep) &"','"& ModiString(bNguoiky) _
						&"','"& bNgaydi &"','"& bNgayky &"',"& bDiachiluutru  _						
						&",'"& ModiString(bNguoinhan) _
						&"','"& ModiString(bTukhoa) &"',"& ModiString(bReadwrite) _
						&","& bTTDuyet &",'"& bNguoiduyet &"','2','"& bSLNoidung &"','"& bSelect2 &"','"& bSelect1 &"','"& bBaocao &"','"& bdonvixuly &"')"					
				Conn.Execute sSQL
				%><%=Err.Description%><%
				bSoghinhancu=bSoghinhan
				bIDcu=bID
				
				'******************
				if bDangky="ok" then
					set Obj=server.CreateObject("ActiveFile.File")
					IDFlow=Request("IDFLow")
					sSQL="Select Tentepxuly from workflow where maworkflow like '"& IDFlow &"'"
					Set RecTT=server.CreateObject("ADODB.Recordset")
					RecTT.CursorType=3
					RecTT.CacheSize=5
					RecTT.Open sSQL,Conn
					if RecTT.RecordCount then
						tentep=RecTT("Tentepxuly")
					end if
					RecTT.Close
					Set RecTT=nothing
					Path1=RootContent & "Data\yeucau\TEXT"  & "\"& IDFlow & ".VT"
					obj.Name=Path1
					fname=bID & ".VT"
										
					'Tao thu muc nam moi
				Set bDir=server.CreateObject("ActiveFile.Directory")
		     	bPathFolder=RootContent & "Upload"& "\" & bNam
		     	
			    bDir.Path=bPathFolder
				if not bDir.Exists() then
					call bDir.Create(bPathFolder)
				end if    				
				bPathFolder=bPathFolder & "\Di"
				bDir.Path=bPathFolder
	     		if not bDir.Exists() then
					Call bDir.Create(bPathFolder)
				end if
				
				bPathFolder=bPathFolder & "\Text"
			    	bDir.Path=bPathFolder
				if not bDir.Exists() then
	   				Call bDir.Create(bPathFolder)
				end if
			     Set bDir=nothing		          							
'				TextFile.Name=Path

				if obj.Exists() then
					obj.Name=RootContent & "upload\"& bNam &"\DI\TEXT\"& replace(fname,"/","_")
					if obj.Exists() then
						obj.Delete()
					end if
					Obj.Name=Path1						
					Path2=RootContent & "upload\"& bNam &"\DI\TEXT\"& replace(fname,"/","_")
					Obj.Copy(Path2)
					bTentep=fname
				else
					loi=true
				end if
				
				Set TextFile=server.CreateObject("Vinalines.ClsFile")
				bTEXT=TextFile.ReadTextFile(path1)
				sSQL="Select Tentep,mota from workflow_tentep where maworkflow like '"& IDFlow &"'"					
				Set RecWF=server.CreateObject("ADODB.Recordset")
				RecWF.CursorType=3
				RecWF.CacheSize=5
				RecWF.Open sSQL,Conn	
				
				if RecWF.RecordCount then
					STT=0
					Do while not RecWF.EOF
						STT=STT+1
						Tentep=replace(bID,"/","_") & "S" & cstr(STT) & "."  & TextFile.GetExtensionFile(RecWF("Tentep"))
						P1=RootContent & "\Data\yeucau" & "\" & RecWF("Tentep")
						Obj.Name=P1						
						if Obj.Exists() then
							P2=RootContent & "upload\"& bNam &"\DI\"& Tentep
							Obj.Copy(P2)
						end if
						sSQL="Insert into vanban_Noidung(Mavanthu,Loaivanthu,SoThutu,tentep,mota) values('"& bID &"','2',"& cstr(STT) &",'"& tentep &"','"& ModiString(RecWF("mota")) &"')"
						Conn.Execute sSQL							
						RecWF.MoveNext
					Loop
				end if
				
				RecWF.Close
				Set RecWF=nothing
				Set TextFile=nothing
				set Obj=nothing
				'Chuyen doi trang thai Workflow
				bMaflowgiaima=giaima(request("maflow")	)
				 sSQL = "Update Flownode Set trangthaixl=2 where Maworkflownode like '" & bMaFlowgiaima & "'"
				Conn.Execute sSQL
				bLen = ItemLast(bMaFlowgiaima) * 2 - 1
				bItem = Left(bMaFlowgiaima, bLen + 4) & "%%"
				For i = ItemLast(bItem) + 2 To (Len(bMaFlowgiaima) - 1) / 2
					bItem = bItem & "00"
				Next
				sSQL = "Update Flownode Set trangthaixl=0 where trangthaixl=-1 and Maworkflownode<>'" & bMaFlowgiaima & "' and Maworkflownode like '" & bItem & "' "
				Conn.Execute sSQL	                  
				Call Xuly(bItem,bMaFlowgiaima,true)
				sSQL="Update flownode set thuhoi=1 where maworkflow='"& left(bMaflowgiaima,5) &"'"
				Conn.Execute sSQL
				%><%=Err.Description%><%
			end if
	'*****************
			'Ket Thuc Transaction								

			if Err.number=0 then
				if Session("VanBan")="" then 
					Session("VanBan")="-" & Session("VanBan") & modistring(bID) & "-"
				else
					Session("VanBan")=Session("VanBan") & modistring(bID) & "-"
				end if
				Session("sSQLDi")=""
				Conn.CommitTrans
				bTrangthai=1
			else
				Conn.RollbackTrans
				bTrangthai=0
			end if
			'Ghi nhan Ai da login thanh cong				
			bHoten=Session("bHoten")
			bNgaygio=cstr(Date()) &" "& cstr(Time())
			bChucnang="C&#7853;p nh&#7853;t V&#259;n th&#432; quyết định"
			bIDTailieu=bSoghinhan
			bDongtac="Th&#234;m m&#7899;i"
			sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
				&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"','"& bTrangthai &"')"
			Conn.Execute sSQL	
			
			Session("bMaVBQD")=bID
			Session("bTenVBQD")=bTrichyeu
		end if
	end select
	if bComm=""  then
		bVuviec=false
	else
		bVuviec=true
	end if
	'Kiem tra(Lay quyen va ma van thu) quyen doi voi van thu
	if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),4)="1" or Session("IsAdmin") then
		bQuyen="F"
	else
		sSQL="Select * from Quyen Where Mavanthu like '"& bID &"' and Macanbo like '"& Session("bMaCB") &"' and maloaivanthu like '2'"
		Set RecKTQ=server.CreateObject("ADODB.Recordset")
		RecKTQ.CursorType=3
		RecKTQ.CacheSize=5
		RecKTQ.Open sSQL,Conn
		if RecKTQ.RecordCount>0 then
			bQuyen=RecKTQ("Quyen")
		end if
		RecKTQ.Close
		set RecKTQ=nothing		
	end if%>	
<%if Msg<>"" then%>
	<p align=center><font face=Arial color=red><%=Msg%></font></p>
<%end if%>	
<!--#include file="..\jvfunction.inc"-->
<script language=vbscript runat=server>
'******Giai ma xau************************
	Function GiaiMa(msText) 
	    Dim nC
	    Dim nD
	    Dim nE
	    Dim lA
	    Dim lB
	    Dim lI
	    Dim lJ
	    Dim lK
	    Dim sB
	    lA = Len(msText)
	    lB = lA - 1 - (lA - 1) \ 4
	    sB = Space(lB)
	    For lI = 1 To lB
	        lJ = lJ + 1
	        nC = Asc(Mid(msText, lJ, 1)) - 59	        
	        Select Case lI Mod 3
	        Case 1
	            lK = lK + 4
	            If lK > lA Then lK = lA
	            nE = Asc(Mid(msText, lK, 1)) - 59
	            nD = ((nE \ 16) And 3) * 64
	        Case 2
	            nD = ((nE \ 4) And 3) * 64
	        Case 0
	            nD = (nE And 3) * 64
	            lJ = lJ + 1
	        End Select
	        sB=Mid(sB,1,lI-1) & Chr(nC Or nD) & Mid(sB,lI+1,len(sB)-lI)
	    Next
	    GiaiMa = sB
	End Function
	Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
	End Function
'Chuyen doi ma
Function DoiMa(st)
    Dim i
    st = Trim(st)
    If Len(st) = 0 Then
        DoiMa = ""
    Else
        For i = 1 To Len(st)
            Select Case Mid(st, i, 1)
                Case "-"
                    st=Replace(st,"-","_")
                Case "+"
                    st=Replace(st,"+","_")
                Case "*"
                    st=Replace(st,"*","_")
                Case "\"            
                    st=Replace(st,"\","_")
                Case "/"
                    st=Replace(st,"/","_")
                Case "?"
                    st=Replace(st,"?","_")
                Case "!"
                    st=Replace(st,"!","_")
                Case ","
                    st=Replace(st,",","_")
                Case ":"
                    st=Replace(st,":","_")
                Case ";"
                    st=Replace(st,";","_")
                Case "^"
                    st=Replace(st,"^","_")
                Case "|"
                    st=Replace(st,"|","_")
                Case " "
                    st=Replace(st," ","_")
                Case "("
                    st=Replace(st,"(","_")
                Case ")"
                    st=Replace(st,")","_")
                Case "["
                    st=Replace(st,"[","_")
                Case "]"
                    st=Replace(st,"]","_")
                Case "{"
                    st=Replace(st,"{","_")
                Case "}"
                    st=Replace(st,"}","_")
                Case "<"
                    st=Replace(st,"<","_")
                Case ">"
                    st=Replace(st,">","_")
                Case "."
                    st=Replace(st,".","_")
            End Select
        Next
        DoiMa = st
    End If
End Function
'Dung de kich hoat dong con khi cha no duoc kich hoat hoac mo di
Function Xulycon(bMa,bActive)
	if bActive then 'Khi nut cha duoc phep xu ly
		sSQL="Select * from flownode where maworkflow like '"& bMa &"' order by maworkflownode"
		Set RecXLC=server.CreateObject("ADODB.Recordset")
		RecXLC.CursorType=3
		RecXLC.CacheSize=5
		RecXLC.Open sSQL,Conn
		Do While not RecXLC.EOF
			bCond=Itemlast(RecXLC("maworkflownode"))
			if bCond=2 then
				sSQL="Update flownode set trangthaixl=0 where trangthaixl=-1 and maworkflownode like '"& RecXLC("maworkflownode") &"'"
				Conn.Execute sSQL
			end if
			RecXLC.MoveNext
		Loop
		RecXLC.Close
		set RecXLC=nothing
	else 'Khi nut cha khong duoc phep xu ly
		sSQL="Update flownode set trangthaixl=-1 where maworkflow like '"& bMa &"'"
		Conn.Execute sSQL
	end if	
End Function
'Xuly cac nut con sau khi nut con cua mot nhanh khac xu ly
Function Xuly(bMaflownode,bCurrent,bActive)
	sSQL="Select * from flownode where maworkflownode like '"& bMaflownode &"' and Maworkflownode<>'" & bCurrent & "'"
	Set RecTimcon=server.CreateObject("ADODB.Recordset")
	RecTimcon.CursorType=3
	RecTimcon.CacheSize=5
	RecTimcon.Open sSQL,Conn
	Do while not RecTimcon.EOF
		if not isnull(RecTimcon("maworkflowcon")) then	
			Call Xulycon(RecTimcon("maworkflowcon"),bActive)
			RecTimcon.MoveNext
		end if
		RecTimcon.MoveNext
	Loop
	RecTimcon.Close
	Set RecTimcon=nothing
End Function
	' H&#224;m &#273;&#7883;nh d&#7841;ng l&#7841;i ng&#224;y M/D/Y-> D/M/Y		
	Function FormatDate(vDate)
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	   End If
	End Function
	Function ModiString(mess_s)
		message = Replace("" & mess_s,"'", "''")
		ModiString=message
	End function
	'Kiem tra so ghi nhan
	Function KTSoghinhan(bValueO,bLoaiVB,bValueY,loai)
		KTSoghinhan=false
		if loai="okedit" then			
			sSQL="Select * from VTDi where phanloai="& bLoaiVB &" and soghinhan='"&trim(bValueO)&"' and year(ngaydi)="& bValueY
			set RecKT=server.CreateObject("ADODB.Recordset")
			RecKT.CursorType=3
			RecKT.CacheSize=5
			RecKT.Open sSQL,Conn
			if RecKT.Recordcount<=0 then
				KTSoghinhan=true
			end if
			RecKT.Close
			set RecKT=nothing
		end if
		if loai="okadd" then
			sSQL="Select ID from vtDi where phanloai="& bLoaiVB &" and soghinhan= '"& trim(bValueO) &"' and year(ngaydi)="& bValueY
			set RecKT=server.CreateObject("ADODB.Recordset")
			RecKT.CursorType=3
			RecKT.CacheSize=5
			RecKT.Open sSQL,Conn
			if RecKT.Recordcount<=0 then
				KTSoghinhan=true
			end if
			RecKT.Close
			set RecKT=nothing		
		end if
	end function
    'Vi tri bit so sanh
Function ItemLast(Item)
        Dim i
        Dim It
        Dim vt
        Dim j, Temp
        It = Item
        It = Right(It, Len(It) - 4)
        j = 1
        For i = 2 To Len(It)
            If i < Len(It) Then
                Temp = Mid(It, i, 1)
                i = i + 1
                Temp = Temp & Mid(It, i, 1)
                j = j + 1
                If Temp = "00" Then
                    ItemLast = j - 1
                    Exit For
                Else
                    If i = Len(It) Then
                        ItemLast = j
                    End If
                End If
            End If
        Next
    End Function
'bg thphuc 25-02-2003
Function Donvixuly(strTendonvixuly)
	check=true
	if strTendonvixuly="" then
		strdonvixuly=""
	else
		strdonvixuly="-"
	end if
	strdonvixulyloi=""
	intlong=len(strTendonvixuly)
	i=0
	i=instr(1,strTendonvixuly,",")
	j=1
	k=0
	l=0
	if i <=0 then
		Set RecDV=server.CreateObject("ADODB.Recordset")
		RecDV.CursorType=3
		RecDV.CacheSize=5
		sSQL="select madonvi from donvi where tendonvi like '"& strTendonvixuly &"'"
		RecDV.Open sSQL,Conn
		if RecDV.Recordcount then
			strdonvixuly="-"+RecDV("madonvi")+"M-"
		else
			strdonvixulyloi=strTendonvixuly
		end if
		RecDV.close
		set RecDV=nothing
	else
		do while check
			Set RecDV=server.CreateObject("ADODB.Recordset")
			RecDV.CursorType=3
			RecDV.CacheSize=5
			sSQL="select madonvi from donvi where tendonvi like '"& mid(strTendonvixuly,j,i-j) &"'"
			RecDV.Open sSQL,Conn
			if RecDV.Recordcount then
				if l=0 then
					strdonvixuly=strdonvixuly+RecDV("madonvi")+"M-"
				else
					strdonvixuly=strdonvixuly+RecDV("madonvi")+"S-"
				end if
			else
				strdonvixulyloi=strdonvixulyloi+mid(strTendonvixuly,j,i-j)+","
			end if
			RecDV.close
			set RecDV=nothing
			k=instr(i+1,strTendonvixuly,",")
			j=i+2
			if k <=0 then
				check=false
				'strdonvixuly=strdonvixuly+mid(strTendonvixuly,j,intlong-j+1)+"-"
				Set RecDV=server.CreateObject("ADODB.Recordset")
				RecDV.CursorType=3
				RecDV.CacheSize=5
				sSQL="select madonvi from donvi where tendonvi like '"& mid(strTendonvixuly,j,intlong-j+1) &"'"
				RecDV.Open sSQL,Conn
				if RecDV.Recordcount then
					strdonvixuly=strdonvixuly+RecDV("madonvi")+"S-"
				else
					strdonvixulyloi=strdonvixulyloi+mid(strTendonvixuly,j,intlong-j+1)+","
				end if
				RecDV.close
				set RecDV=nothing
			else
				check=true
			end if
			i=k
			l=l+1
		loop
	end if
	if strdonvixulyloi="" then
		Donvixuly=strdonvixuly
	else
		Donvixuly=strdonvixuly+"#"+strdonvixulyloi
	end if
End function
'ed thphuc 25-02-2003
</script>	
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function SetFocus(){
	if (Noidung.TxtOutNum.disabled==false){
		Noidung.TxtOutNum.focus();
	}
}

function CmdDuyet_onclick() {
	<%if bComm="add" then %>
		alert("Bạn phải ghi nhận công văn trước");
		return false;
	<%end if%>
	if (!Noidung.CheckReadwrite.Checked){
	<%if bReadwrite then %>
		alert("Bạn phải ghi nhận công văn trước");
		return false;
	<%end if%>
	}
	mavt=window.Noidung.TxtID.value;
	window.Noidung.target="right";
	//bduyet="duyetcanbo.asp?bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bstepduyet=0&bCommDuyetCB="+'<%=bComm%>'+"&MaVT="+mavt+"&bMaLoaiVT=2";
	bduyet="duyetcanbodvxl.asp?bstepduyet=0&bCommDuyetCB="+"<%=bComm%>"+"&MaVT="+mavt+"&bMaLoaiVT=2";
	window.Noidung.action=bduyet
	window.Noidung.submit();
}

function CmdAdd_onclick() {
	<%if bDangky="ok" then%>
		window.Noidung.action="frmvtDi.asp?FilenameChuyen="+"<%=request("Filenamechuyen")%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=add";
	<%else%>
		window.Noidung.action="frmvtDi.asp?bComm=add";
	<%end if%>	
	window.Noidung.target="right";
	window.Noidung.submit();
}

function KTNhap(){
	if(trim(Noidung.TxtOutSymbol.value)==""){
		alert("Bạn cần phải nhập ký hiệu");
		Noidung.TxtOutSymbol.focus();
		return false;
	}
	if (trim(Noidung.TxtTrichyeu.value)==""){
		alert("Bạn cần phải nhập trích yếu");
		Noidung.TxtTrichyeu.focus();
		return false;
	}
	if (trim(Noidung.TxtNgayky.value)==""){
		alert("Bạn cần phải nhập ngày ký");
		Noidung.TxtNgayky.focus();
		return false;
	}	
	if (!isDate(Noidung.TxtNgayky.value)){
		alert("Ngày ký không hợp lệ");
		Noidung.TxtNgayky.focus();
		return false;
	}
	if (trim(Noidung.TxtNguoiky.value)==""){
		alert("Bạn cần phải nhập người ký");
		Noidung.TxtNguoiky.focus();
		return false;
	}
	if (trim(Noidung.ComboTinhchat.value)==""){
		alert("Bạn cần phải nhập tính chất");
		Noidung.ComboTinhchat.focus();
		return false;
	}
	return true;
}

function CmdOK_onclick() {	
	if (KTNhap()){
		if (!IsNumeric(Noidung.TxtOutNum.value)){
				alert("Số công văn không hợp lệ");
				Noidung.TxtOutNum.focus();
				return false;			
		}	
		if(trim(Noidung.TxtNgayky.value)!=""){	
			if (!isDate(Noidung.TxtNgayky.value)){
				alert("Ngày ký không hợp lệ");
				Noidung.TxtNgayky.focus();
				return false;
			}
		}
		<% if Request("ChuyenVTDi")="ok" then%>
		//Noidung.CboOutSymbol.value=Noidung.PL.value;
		<%end if%>
		Noidung.TxtOutNum.disabled=false;
		Noidung.TxtOutSymbol.disabled=false;
		donvisoan=window.Noidung.select1.value;
		<%if bComm="edit" then%>
			window.Noidung.target="right"
			//window.Noidung.action="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+ "<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet="+ "<%=bTTDuyet%>"
			window.Noidung.action="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+ "<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bNhomCVcu="+"<%=bNhomCVcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet="+ "<%=bTTDuyet%>"+"&bghinhan=true"+"&bselect1="+donvisoan
		window.Noidung.submit()
		<%end if%>
		<%if bComm="add" then%>			
			window.Noidung.target="right";
			//window.Noidung.action="frmvtDi.asp?bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+ "&IDFlow="+"<%=request("IDFLow")%>"+"&bComm=okadd"+"&bReadwrite=" +Noidung.CheckReadwrite.checked+"&bTTDuyet=false&maflow="+"<%=maflow%>";
			window.Noidung.action="frmvtDi.asp?bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+ "&IDFlow="+"<%=request("IDFLow")%>"+"&bComm=okadd"+"&bReadwrite=" +Noidung.CheckReadwrite.checked+"&bTTDuyet=false&maflow="+"<%=maflow%>"+"&bselect1="+donvisoan;
			window.Noidung.submit()
		<%end if%>
	}
}
function CmdOKDuyet_onclick(){
		Noidung.TxtOutNum.disabled=false;
		<%if bComm="add" then %>
			alert("Bạn cần phải ghi nhận công văn trước");
			return false;
		<%end if%>
		if (KTNhap()){
		if(Noidung.TxtNgayky.value!=""){	
			if (!isDate(Noidung.TxtNgayky.value)){
				alert("Ngày ký không hợp lệ");
				Noidung.TxtNgayky.focus();
				return false;
			}
		}
		Noidung.TxtOutSymbol.disabled=false;
		<%if bComm="edit" then%>
			donvisoan=window.Noidung.select1.value;
			window.Noidung.target="right"
//window.Noidung.action="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet=True"
			window.Noidung.action="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bNhomCVcu="+"<%=bNhomCVcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet=True"+"&bghinhan=true"+"&bselect1="+donvisoan;
			window.Noidung.submit()
		<%end if%>
	}
}
function CmdNotOKDuyet_onclick(){
	
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");
		return false;
	<%end if%>
		if (KTNhap()){
		if(trim(Noidung.TxtNgayky.value)!=""){	
			if (!isDate(Noidung.TxtNgayky.value)){
				alert("Ngày ký không hợp lệ");				
				Noidung.TxtNgayky.focus();
				return false;
			}
		}
		Noidung.TxtOutSymbol.disabled=false;
		Noidung.TxtOutNum.disabled=false;
		<%if bComm="edit" then%>
			Noidung.target="right"
			//Noidung.action="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bNhomCVcu="+"<%=bNhomCVcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet=false"
			Noidung.action="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bNhomCVcu="+"<%=bNhomCVcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet=false"+"&bghinhan=false"+"&bTukhoa="+"<%=server.urlencode(bTukhoa)%>"+"&bDiachiluuTru="+"<%=bDiachiluuTru%>"+"&bSelect1="+"<%=server.urlencode(bSelect1)%>"+"&bSelect2="+"<%=server.urlencode(bSelect2)%>"+"&bBaocao="+"<%=server.urlencode(bBaocao)%>"+"&bCongcong="+"<%=bCongcong%>"+"&bSLNoidung="+"<%=server.urlencode(bSLNoidung)%>"+"&bSoban="+"<%=bSoban%>"+"&bSoto="+"<%=bSoto%>"+"&bnoinhan="+"<%=server.urlencode(bnoinhan)%>"+"&bNguoinhan="+"<%=server.urlencode(bNguoinhan)%>"+"&bNam="+"<%=bNam%>"+"&bNGaydi="+"<%=bNGaydi%>"+"&bNGayky="+"<%=bNGayky%>"+"&bNguoiky="+"<%=server.urlencode(bNguoiky)%>"+"&bTentep="+"<%=server.urlencode(bTentep)%>"+"&bTinhchat1="+"<%=bTinhchat1%>"+"&bTinhchat="+"<%=bTinhchat%>"+"&bTomtat="+"<%=server.urlencode(trim(bTomtat))%>"+"&bTrichyeu="+"<%=server.urlencode(bTrichyeu)%>"+"&bOutSymbol="+"<%=bOutSymbol%>"+"&bOutnum="+"<%=bOutnum%>"+"&bPhanloai="+"<%=bPhanloai%>"
		Noidung.submit()
		<%end if%>
	}
}
function CmdExit_onclick() {	
	<%if Request("bDangky")="ok" then%>
		window.history.go(-<%=Backform%>);
	<%else%>
		Noidung.target="right"
		Noidung.action="<%=Session("tenvtdi")%>?bComm=";
		Noidung.submit();
	<%end if%>
}

function CmdCancel_onclick() {
	Noidung.CmdOK.disabled=true;
	Noidung.CmdCancel.disabled=true;
}
function CmdXacnhan_onclick() {
	if(Noidung.TxtPsw.value=="<%=Giaima(Session("Pass"))%>"){
		if(Noidung.CheckDuyet.disabled){
			Noidung.CheckDuyet.disabled=false;
			Noidung.CmdNoidungtep.disabled=false;
		}
		else{
			Noidung.CheckDuyet.disabled=true;
			Noidung.CmdNoidungtep.disabled=true;
		}
		return true
	}
	else{
		alert("B&#7841;n x&#225;c nh&#7853;n sai m&#7853;t kh&#7849;u !")
		return false;
	}
	Noidung.TxtPsw.value="";
}
function CheckReadwrite_onclick(){
	if (Noidung.CheckReadwrite.checked){
		Noidung.CmdDuyet.disabled=true;
		<%if bTTDuyet then%>
			if (KTNhap()){
			if(trim(Noidung.TxtNgayky.value)!=""){	
				if (!isDate(Noidung.TxtNgayky.value)){
					alert("Ngày ký không hợp lệ");
					Noidung.TxtNgayky.focus();
					return false;
				}
			}
			Noidung.target="right";
			strcc="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bNhomCVcu="+"<%=bNhomCVcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet="+"<%=bTTDuyet%>"+"&bghinhan=false"+"&bTukhoa="+"<%=server.urlencode(bTukhoa)%>"+"&bDiachiluuTru="+"<%=bDiachiluuTru%>"+"&bSelect1="+"<%=server.urlencode(bSelect1)%>"+"&bSelect2="+"<%=server.urlencode(bSelect2)%>"+"&bBaocao="+"<%=server.urlencode(bBaocao)%>"+"&bCongcong="+"<%=bCongcong%>"+"&bSLNoidung="+"<%=bSLNoidung%>"+"&bSoban="+"<%=bSoban%>"+"&bSoto="+"<%=bSoto%>"+"&bnoinhan="+"<%=server.urlencode(bnoinhan)%>"+"&bNguoinhan="+"<%=server.urlencode(bNguoinhan)%>"+"&bNam="+"<%=bNam%>"+"&bNGaydi="+"<%=bNGaydi%>"+"&bNGayky="+"<%=bNGayky%>"+"&bNguoiky="+"<%=server.urlencode(bNguoiky)%>"+"&bTentep="+"<%=server.urlencode(bTentep)%>"+"&bTinhchat1="+"<%=bTinhchat1%>"+"&bTinhchat="+"<%=bTinhchat%>"+"&bTomtat="+"<%=server.urlencode(trim(bTomtat))%>"+"&bTrichyeu="+"<%=server.urlencode(bTrichyeu)%>"+"&bOutSymbol="+"<%=bOutSymbol%>"+"&bOutnum="+"<%=bOutnum%>"+"&bPhanloai="+"<%=bPhanloai%>";
			Noidung.action=strcc;
			Noidung.submit();
			}
		<%end if%>
	}		
	else
	{	
		Noidung.CmdDuyet.disabled=false;
		<%if bTTDuyet then%>
			if (KTNhap()){
				if(trim(Noidung.TxtNgayky.value)!=""){	
					if (!isDate(Noidung.TxtNgayky.value)){
						alert("Ngày ký không hợp lệ");
						Noidung.TxtNgayky.focus();
						return false;
					}
				}
				Noidung.target="right";
				strcc="frmvtDi.asp?bSoghinhancu="+"<%=bSoghinhancu%>"+"&bDangky="+"<%=bDangky%>"+"&Backform="+"<%=backform%>"+"&bComm=okedit&bIDcu="+"<%=bIDcu%>"+"&bPhanloaicu="+"<%=bPhanloaicu%>"+"&bNamcu="+"<%=bNamcu%>"+"&bNhomCVcu="+"<%=bNhomCVcu%>"+"&bOutnumcu="+"<%=bOutnumcu%>"+"&bReadwrite="+Noidung.CheckReadwrite.checked+"&bTTDuyet="+"<%=bTTDuyet%>"+"&bghinhan=false"+"&bTukhoa="+"<%=server.urlencode(bTukhoa)%>"+"&bDiachiluuTru="+"<%=bDiachiluuTru%>"+"&bSelect1="+"<%=server.urlencode(bSelect1)%>"+"&bSelect2="+"<%=server.urlencode(bSelect2)%>"+"&bBaocao="+"<%=server.urlencode(bBaocao)%>"+"&bCongcong="+"<%=bCongcong%>"+"&bSLNoidung="+"<%=bSLNoidung%>"+"&bSoban="+"<%=bSoban%>"+"&bSoto="+"<%=bSoto%>"+"&bnoinhan="+"<%=server.urlencode(bnoinhan)%>"+"&bNguoinhan="+"<%=server.urlencode(bNguoinhan)%>"+"&bNam="+"<%=bNam%>"+"&bNGaydi="+"<%=bNGaydi%>"+"&bNGayky="+"<%=bNGayky%>"+"&bNguoiky="+"<%=server.urlencode(bNguoiky)%>"+"&bTentep="+"<%=server.urlencode(bTentep)%>"+"&bTinhchat1="+"<%=bTinhchat1%>"+"&bTinhchat="+"<%=bTinhchat%>"+"&bTomtat="+"<%=server.urlencode(trim(bTomtat))%>"+"&bTrichyeu="+"<%=server.urlencode(bTrichyeu)%>"+"&bOutSymbol="+"<%=bOutSymbol%>"+"&bOutnum="+"<%=bOutnum%>"+"&bPhanloai="+"<%=bPhanloai%>";
				Noidung.action=strcc;
				Noidung.submit();
			}
		<%end if%>
	}
}

function CmdXemNoidung_onclick(){	
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");
		return false;
	<%end if%>	
	if (Noidung.TxtID.value!=""){
		window.Noidung.target="_blank";
		bMa=Noidung.TxtID.value;
		window.Noidung.action="xemnoidung.asp?LoaiVt=2&bMa="+bMa+"&bNam="+"<%=bNam%>"
		window.Noidung.submit();
	}
}
function CmdNoidungtep_onclick() {	
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");
		return false;
	<%end if%>	
	<%if bQuyen="" or bQuyen="R" then%>
		alert("B&#7841;n kh&#244;ng c&#243; quy&#7873;n s&#7917;a &#273;&#7893;i n&#7897;i dung v&#259;n th&#432;");
		return false;
	<%end if%>
	<% if bComm="edit" then%>
		bMa=Noidung.TxtID.value;
//HienSX
		a="../editor/frmedit.asp?bMa="+bMa+"&bLoaiVT=2&bNam="+"<%=bNam%>"+"&bNamcu="+"<%=bNamCu%>"+"&sort="+Noidung.Sort.value;
		window.Noidung.action=a;
		window.Noidung.target="right";
		window.Noidung.submit();
	<%end if%>		
}
function cmddangkyvv_onclick() {
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");
		return false;
	<%end if%>
	<%if bVuviec then%>
		window.Noidung.target="main";
		window.Noidung.action="dangkyvuviec/frmdangky.asp?LoaiVt=2";
		window.Noidung.submit();
	<%else%>
		alert("B&#7841;n c&#7847;n ph&#7843;i ch&#7885;n v&#259;n th&#432; &#273;&#7875; &#273;&#259;ng k&#253;");
	<%end if%>
}
function CmdThemVV_onclick() {
	<%if bComm="add" then %>
		alert("Bạn cần phải ghi nhận công văn trước");		
		return false;
	<%end if%>
	<%if bVuviec then%>
		window.Noidung.target="right"
		window.Noidung.action="frmvuviec.asp?bcallfrmvtden=ok&bTrichyeuvtden="+Noidung.TxtTrichyeu.value;
		window.Noidung.submit();
	<%else%>
		alert("B&#7841;n c&#7847;n ph&#7843;i ch&#7885;n m&#7897;t v&#259;n th&#432; l&#224;m vi&#7879;c");
	<%end if%>
}

function ComboNguoiky_onchange() {
	Noidung.TxtNguoiky.value=Noidung.ComboNguoiky.value;
}
function ComboNguoinhan_onchange() {
	Noidung.TxtNguoinhan.value=Noidung.ComboNguoinhan.value;
}
/*
function openNN(sObj) {
  popupWin = window.open('Search.asp?bType=DI','new_page','width=300,height=300').focus();
}

function openDV(sObj) {
  popupWin = window.open('AddDV.asp?bType=DI','new_page','width=300,height=300').focus();
}
function openNguoiky(sObj) {
  popupWin = window.open('AddNguoiky.asp?bType=DI','new_page','width=300,height=300').focus();
}

*/
function CmdEmail_onclick() {
	Noidung.target="_blank";
	bMa=Noidung.TxtID.value;
	Noidung.action="compose.asp?bLoaiVt=2&bMa="+bMa+"&bNam="+"<%=bNam%>";
	Noidung.submit();
}

function TxtNgayky_onkeyup(str){
	var keycode
	keycode=window.event.keyCode
	if (isEdit(keycode,str)){
		Noidung.TxtNgayky.value=editdate(trim(str))
	}
}

function TxtNgaydi_onkeyup(str){
	var keycode
	keycode=window.event.keyCode
	if (isEdit(keycode,str)){
		Noidung.TxtNgaydi.value=editdate(trim(str))
	}
}

function TxtOutSymbol_onkeyup(str){
var keycode
keycode=window.event.keyCode
var strOutSymbol
//alert (keycode);
//33 34 35 36 37 38 39 40 8 46
	if ((keycode!=33)&&(keycode!=34)&&(keycode!=35)&&(keycode!=36)&&(keycode!=37)&&(keycode!=38)&&(keycode!=39)&&(keycode!=40)&&(keycode!=8)&&(keycode!=45)&&(keycode!=46)){
		strOutSymbol=Noidung.TxtOutSymbol.value;
		Noidung.TxtOutSymbol.value=strOutSymbol.toUpperCase();
		Noidung.TxtOutSymbol.focus();
	}
	if (keycode==9){
		Noidung.TxtOutSymbol.select();
	}
	
}

//Hien NN
function select2_onkeydown(){
var keycode  
keycode=window.event.keyCode;
str=Noidung.select2.value;
strtruoc="";
	if (keycode==13){
		if (str==""){
			eval('ListRecordNN(str,escape(strtruoc),"Noidung.select2.value",260,250,270,400)');
			return false;
		
		}else{
			intpc=str.lastIndexOf(",");
			strtruoc=str.substr(0,intpc+1);
			str=str.substr(intpc+1,str.length-intpc);
			str=trim(str);
			if (strtruoc.length>0){
				strtruoc+=" ";
			}

			if (CheckMaNN(str)==1){
				Noidung.select2.value=strtruoc+FindOneMaNN(str);
				return false;
			}else{
				if (CheckMaNN(str)==0){
					if (CheckTenNN(str)==1){
						Noidung.select2.value=strtruoc+FindOneTenNN(str);
						return false;
					}else{
						if (CheckTenNN(str)>1){
							eval('ListRecordNN(str,escape(strtruoc),"Noidung.select2.value",260,250,270,400)');
							return false;	
						}else{
							Noidung.select2.value=strtruoc+str;
							return false;	
						}
					}
				}else{
					eval('ListRecordNN(str,escape(strtruoc),"Noidung.select2.value",260,250,270,400)');
					return false;
				}
			}
		}
	}
}
function CmdNN_onclick(){
	str="";
	strtruoc=Noidung.select2.value;
	if (strtruoc.length>0){
		strtruoc=strtruoc+", "
	}
	eval('ListRecordNN(str,escape(strtruoc),"Noidung.select2.value",260,250,270,400)');
	return false;
}
//Hien NK
function TxtNguoiky_onkeydown(){
var keycode  
keycode=window.event.keyCode;
str=Noidung.TxtNguoiky.value;
strtruoc="";
	if (keycode==13){
		if (str==""){
			eval('ListRecordNK(str,escape(strtruoc),"Noidung.TxtNguoiky.value",215,220,300,400)');
			return false;
		}else{
			intpc=str.lastIndexOf(",");
			strtruoc=str.substr(0,intpc+1);
			str=str.substr(intpc+1,str.length-intpc);
			str=trim(str);
			if (strtruoc.length>0){
				strtruoc+=" ";
			}

			if (CheckMaNK(str)==1){

				Noidung.TxtNguoiky.value=strtruoc+FindOneMaNK(str);
				return false;
			}else{
				if (CheckMaNK(str)==0){
					if (CheckTenNK(str)==1){
						Noidung.TxtNguoiky.value=strtruoc+FindOneTenNK(str);
						return false;
					}else{
						if (CheckTenNK(str)>1){
							eval('ListRecordNK(str,escape(strtruoc),"Noidung.TxtNguoiky.value",215,220,300,400)');
							return false;	
						}else{
							Noidung.TxtNguoiky.value=strtruoc+str;
							return false;	
						}
					}
				}else{
					eval('ListRecordNK(str,escape(strtruoc),"Noidung.TxtNguoiky.value",215,220,300,400)');
					return false;
				}
			}
		}
	}
}
function CmdNK_onclick(){
	str="";
	strtruoc=Noidung.TxtNguoiky.value;
	if (strtruoc.length>0){
		strtruoc=strtruoc+", "
	}
	eval('ListRecordNK(str,escape(strtruoc),"Noidung.TxtNguoiky.value",215,220,300,400)');
	return false;
}
//Hien DVSoan
function select1_onkeydown(){
var keycode  
keycode=window.event.keyCode;
str=Noidung.select1.value;
strtruoc="";
	if (keycode==13){
		if (str==""){
			eval('ListRecordDV(str,escape(strtruoc),"Noidung.select1.value",245,250,150,200)');
			return false;
		}else{
			intpc=str.lastIndexOf(",");
			strtruoc=str.substr(0,intpc+1);
			str=str.substr(intpc+1,str.length-intpc);
			str=trim(str);
			if (strtruoc.length>0){
				strtruoc+=" ";
			}
			if (CheckMaDV(str)==1){
				Noidung.select1.value=strtruoc+FindOneMaDV(str);
				return false;
			}else{
				if (CheckMaDV(str)==0){
					if (CheckTenDV(str)==1){
						Noidung.select1.value=strtruoc+FindOneTenDV(str);
						return false;
					}else{
						if (CheckTenDV(str)>1){
							eval('ListRecordDV(str,escape(strtruoc),"Noidung.select1.value",245,250,150,200)');
							return false;
						}else{
							Noidung.select1.value=strtruoc+str;
							return false;
						}
					}
				}else{
					eval('ListRecordDV(str,escape(strtruoc),"Noidung.select1.value",245,250,150,200)');
					return false;
				}
			}
		}
	}
}
function CmdDV_onclick(){
	str="";
	strtruoc=Noidung.select1.value;
	if (strtruoc.length>0){
		strtruoc=strtruoc+", "
	}
	eval('ListRecordDV(str,escape(strtruoc),"Noidung.select1.value",245,300,150,200)');
	return false;
}

//Hien SKH
function TxtOutSymbol_onkeydown(){
var keycode
keycode=window.event.keyCode;
str=Noidung.TxtOutSymbol.value;
	if (keycode==13){
		if (str==""){
			eval('ListRecordSKH(str,"Noidung.TxtOutSymbol.value","Noidung.select1.value",200,200,180,350)');
			return false;
		}else{
			if (CheckMaSKH(str)==1){
				Noidung.TxtOutSymbol.value=FindOneMaSKH(str);
				Noidung.select1.value=FindOneMaSKH_1(str);
				return false;
			}else{
				if (CheckMaSKH(str)==0){
					if (CheckKyhieu(str)==1){
						Noidung.TxtOutSymbol.value=FindOneKyhieu(str);
						Noidung.select1.value=FindOneKyhieu_1(str);
						return false;
					}else{
						if (CheckKyhieu(str)>1){
							eval('ListRecordSKH(str,"Noidung.TxtOutSymbol.value","Noidung.select1.value",200,200,180,350)');
							return false;
						}else{
							Noidung.TxtOutSymbol.value=str;
							Noidung.select1.value="";
							return false;
						}
					}
				}else{
					eval('ListRecordSKH(str,"Noidung.TxtOutSymbol.value","Noidung.select1.value",200,200,180,350)');
					return false;
				}
			}

		}
	}
}
function CboOutSymbol_onchange(){
	cstr=Noidung.CboOutSymbol.value;
	/*if(cstr==3){
		Noidung.TxtOutSymbol.value="TCHQ/QĐ";
	}
	else
	{
		Noidung.TxtOutSymbol.value="";
	}*/
}
//-->
</SCRIPT>
<body bgcolor="#F8F9D9" topmargin="0" leftmargin="0" style="font-family:Times New Roman" onload="SetFocus()">
<Form name="Noidung" Method="Post">
<!-- HienSX -->
<Input TYPE="hidden" name="Sort" value="<%=sort%>">
<input type=hidden name=chuyendi value="<%=trim(chuyendi)%>">
<%if bDisplay then
	txt="<td width='200' align='left'><input type=hidden name='TxtID' size='50' value='"& bID &"' style='font-family:Arial'></td>"
	Response.Write(txt)
else
	if bComm<>"add" then
		txt="<td width='200' align='left'><input type=hidden name='TxtID' value='"& bID &"' size='50' style='font-family:Arial'></td>"
		Response.Write(txt)
	else
		txt="<td width='200' align='left'><input type=hidden name='TxtID' value='' size='50' style='font-family:Arial'></td>"
		Response.Write(txt)
	end if
end if%>
<!-- Form nhap lieu -->
<table width="100%" border="0" cellspacing="0" style="font-size:12pt;BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" bgcolor="#BDD5D0">
  <tr>
    <td width="100%" colspan="5" bgcolor="#000080" align=center><span style="font-size: 11pt;color=#FFFFFF"><b>CÔNG VĂN ĐI</b></span></td>
  </tr>
  <tr>
<!-- Begin LoaiCV -->
    <td width="14%">Loại CV</td>
	<td width="30%">
   	<%if bTTDuyet then%>
		<Select name=CboOutSymbol disabled style="font-family:Arial;width:100%"  LANGUAGE=javascript onchange="return CboOutSymbol_onchange()" tabindex=1>
	<%else%>
		<Select name=CboOutSymbol style="font-family:Arial;width:100%" LANGUAGE=javascript onchange="return CboOutSymbol_onchange()" tabindex=1>
	<%end if%>
		<%sSQL="Select * from Phan_loai_DI order by Ten_hinh_thuc"
		Set RecPL=Server.CreateObject("ADODB.Recordset")
		RecPL.CursorType=3
		RecPL.CacheSize=5
		RecPL.Open sSQL,Conn
		Do While not RecPL.EOF
			if bDisplay then
				if cint(bPhanloai)=cint(RecPL("IDLoai")) then %>
					<option selected value=<%=RecPL("IDLoai")%>><%=RecPL("TEN_HINH_THUC")%></option>
				<%else%>
					<option value=<%=RecPL("IDLoai")%>> <%=RecPL("TEN_HINH_THUC")%></option>
				<%end if%>
			<%else
				if bComm<>"add"then
					if cint(bPhanloai)=cint(RecPL("IDLoai")) then %>
						<option selected value=<%=RecPL("IDLoai")%>> <%=RecPL("TEN_HINH_THUC")%></option>
					<%else%>
						<option value=<%=RecPL("IDLoai")%>> <%=RecPL("TEN_HINH_THUC")%></option>
					<%end if
				else%>
					<option value=<%=RecPL("IDLoai")%>> <%=RecPL("TEN_HINH_THUC")%></option>
			<%  end if
			end if
		RecPL.MoveNext
		Loop
		RecPL.Close
		Set RecPL=nothing
		%>
	</select>
</td>
<!--End LoaiCV -->
	<td width="16%" align=center nowrap>Số, Ký hiệu</td>
   	<%if bTTDuyet then%>
		<td width="17%"><input name='TxtOutNum' disabled value='<%=bOutNum%>' size=10  maxLength=20 style='font-family:Arial' tabindex=2>/</td>
		<td width="23%"><input name=TxtOutSymbol disabled size=20 value='<%=bOutSymbol%>' style="font-family:Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtOutSymbol_onkeyup(this.value)" onkeydown="return TxtOutSymbol_onkeydown()" tabindex=3></td>
	<%else%>
		<td width="17%"><input name='TxtOutNum' value='<%=bOutNum%>' size=10  maxLength=20 style='font-family:Arial' tabindex=2>/</td>
		<td width="23%"><input name=TxtOutSymbol size=20 value='<%=bOutSymbol%>' style="font-family:Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtOutSymbol_onkeyup(this.value)" onkeydown="return TxtOutSymbol_onkeydown()" tabindex=3></td>
	<%end if%>
 </tr>
  <tr>
    <td width="14%">Ngày ký</td>
	<td width="30%">
   	<%if bTTDuyet then%>
		<input type="text" name=TxtNgayky disabled value='<%=formatdate(bNgayky)%>' size=10 maxLength=10 style='font-family:Arial;width:100%' LANGUAGE=javascript onkeyup="return TxtNgayky_onkeyup(this.value)" tabindex=4>
	<%else%>
		<%if bDisplay then%>
			<input type="text" name=TxtNgayky value='<%=formatdate(bNgayky)%>' size=10 maxLength=10 style='font-family:Arial;width:100%' LANGUAGE=javascript onkeyup="return TxtNgayky_onkeyup(this.value)" tabindex=4>
		<%else
			if bComm<>"add" then%>
				<input type="text" name=TxtNgayky value='<%=formatdate(bNgayky) %>' size=10 maxLength=10 style='font-family:Arial;width:100%' LANGUAGE=javascript onkeyup="return TxtNgayky_onkeyup(this.value)" tabindex=4>
			<%else%>
				<% if Session("defaultNgayKy")="" then
						Session("defaultNgayKy")=Date
				  end if
				%>
				<input type="text" name=TxtNgayky value="<%= FormatDate(Session("defaultNgayKy")) %>" size=10 maxLength=10 style='font-family:Arial;width:100%' LANGUAGE=javascript onkeyup="return TxtNgayky_onkeyup(this.value)" tabindex=4>
			<%end if
		end if
	end if%>
	</td>
   	<%if bTTDuyet then%>
		<td width="16%" align="center"><input type=button disabled onclick="javascript:CmdDV_onclick()" value="Đơn vị soạn" name=CmdDonvi style="font-family:Times New Roman;font-size:11pt;width:100%; background-color=#BDD5D0"></td>
		<td width="40%" colspan=2><input type="text" name="select1" disabled maxlength=500 value="<%=bselect1%>" style="font-family:Arial;width:100%" size=20 onkeydown="return select1_onkeydown()" tabindex=5></td>
	<%else%>
		<td width="16%" align="center"><input type=button onclick="javascript:CmdDV_onclick()" value="Đơn vị soạn" name=CmdDonvi style="font-family:Times New Roman;font-size:11pt;width:100%; background-color=#BDD5D0"></td>
		<td width="40%" colspan=2><input type="text" name="select1" maxlength=500 value="<%=bselect1%>" style="font-family:Arial;width:100%" size=20 onkeydown="return select1_onkeydown()" tabindex=5></td>
	<%end if%>
  </tr>

  <tr>
    <td width="14%">Trích yếu</td>
	<td width="86%" colspan="4">
	<%if bTTDuyet then%>
		<textarea name=TxtTrichyeu disabled maxLength=255 style='font-family:Arial;width:100%' rows=2 tabindex=6 cols="20"><%=bTrichyeu%></textarea></td>
	<%else%>
		<%if bDisplay then%>
			<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=2 tabindex=6 cols="20"><%=bTrichyeu%></textarea></td>
		<%else
			if bComm<>"add" then%>
				<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=2 tabindex=6><%=bTrichyeu %></textarea></td>
			<%else
				if Request("ChuyenVTDi")="ok" then
					Set RecTY=server.CreateObject("ADODB.Recordset")
					RecTY.CursorType=3
					RecTY.CacheSize=5
					sSQL="Select Tenvuviec from workflow where Maworkflow like '"& Request("IDFlow") &"'"
					RecTY.Open sSQL,Conn
					if RecTY.RecordCount then
						if trim(RecTY("Tenvuviec"))<>"" then%>
							<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=2 tabindex=6><%=RecTY("Tenvuviec")%></textarea></td>
						<%else%> 
							<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=2 tabindex=6></textarea></td>
						<%end if%>
					<%else%>
						<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=2 tabindex=6></textarea></td>
					<%end if
					RecTY.Close
					set RecTY=nothing
				else%>
					<textarea name=TxtTrichyeu maxLength=255 style='font-family:Arial;width:100%' rows=2 tabindex=6><%=bTrichyeu%></textarea></td>
				<%end if
			end if
		end if
	end if%>
  </tr>
  <tr>
	<%if bTTDuyet then%>
		<td width="14%"><input type=button onclick="javascript:CmdNN_onclick()" disabled value="Nơi nhận" name=CmdNoinhan style="font-family:Times New Roman;font-size:11pt; width:100%; background-color=#BDD5D0"></td>
		<td width="86%" colspan="4">
		<input type="text" name=select2 disabled maxlength=500 value="<%=bselect2%>" style="font-family:Arial;width:100%" onkeydown="return select2_onkeydown()" tabindex=7 size="20"></td>
	<%else%>
		<td width="14%"><input type=button onclick="javascript:CmdNN_onclick()" value="Nơi nhận" name=CmdNoinhan style="font-family:Times New Roman;font-size:11pt; width:100%; background-color=#BDD5D0"></td>
		<td width="86%" colspan="4">
		<input type="text" name=select2 maxlength=500 value="<%=bselect2%>" style="font-family:Arial;width:100%" onkeydown="return select2_onkeydown()" tabindex=7 size="20"></td>
	<%end if%>
  </tr>
  
  <tr>
    <td width="14%">
	<%if bTTDuyet then%>
		<input type=button disabled onclick="javascript:CmdNK_onclick()" value="Người ký" name=CmdNguoiky style="font-family:Times New Roman;font-size:11pt;width:100%;background-color=#BDD5D0"></td>    
		<td width="86%" colspan=4><input type="text" disabled name=TxtNguoiky size=25 value='<%=bNguoiky%>' maxLength=60 style='font-family:Arial;width:100%' onkeydown="return TxtNguoiky_onkeydown()" tabindex=8></td>
	<%else%>
		<input type=button onclick="javascript:CmdNK_onclick()" value="Người ký" name=CmdNguoiky style="font-family:Times New Roman;font-size:11pt;width:100%;background-color=#BDD5D0"></td>    
		<td width="86%" colspan=4><input type="text" name=TxtNguoiky size=25 value='<%=bNguoiky%>' maxLength=60 style='font-family:Arial;width:100%' onkeydown="return TxtNguoiky_onkeydown()" tabindex=8></td>
	<%end if%>
  </tr>
  <tr>
    <td width="14%">Tóm tắt ND</td>
	<%if bTTDuyet then%>
		<td width="86%" colspan="4"><Textarea name=TxtTomtat disabled maxlength=500 style='font-family:Arial; width:100%' rows="2" tabindex=9 cols="20"><%=trim(bTomtat)%></textarea></td>
	<%else%>
		<td width="86%" colspan="4"><Textarea name=TxtTomtat maxlength=500 style='font-family:Arial; width:100%' rows="2" tabindex=9 cols="20"><%=trim(bTomtat)%></textarea></td>
	<%end if%>
  </tr>
  <tr>
    <td width="14%" nowrap>Khẩn/mật</td>
    <td width="30%" nowrap>
	<%if bTTDuyet then%>
		<select size="1" name="ComboTinhchat" disabled style="font-family: Arial; height: 23; position: relative; width:100%" tabindex=10>
	<%else%>
		<select size="1" name="ComboTinhchat" style="font-family: Arial; height: 23; position: relative; width:100%" tabindex=10>
	<%end if%>
		<%
			sSQL="Select * from Tinhchat"
			Set RecTC=Server.CreateObject("ADODB.Recordset")
			RecTC.CursorType=3
			RecTC.CacheSize=5
			RecTC.Open sSQL,Conn
			Do While not RecTC.EOF
				if bDisplay then
					if RecTC("ma")=bTinhchat then%>
						<option Selected value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
					<%else%>
						<option value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
					<%end if
				else%>
					<%if bComm<>"add" then
						if RecTC("ma")=bTinhchat then%>
							<option Selected value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
						<%else%>
							<option value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
						<%end if
					else%>
						<option value=<%=RecTC("Ma")%>><%=RecTC("Ten")%>
					<%end if%>
			<%end if
			RecTC.MoveNext
			Loop
			RecTC.Close
			set RecTC=nothing
		%>
		</select>
	</td>
	<%if bTTDuyet then%>	
	  	<td width="16%" nowrap>Số bản <input type="text" name=TxtSoban disabled value="<%=bSoban%>" style="font-family:Arial" size=2 maxlength=4 tabindex=11></td>
		<td width="17%" nowrap>Số tờ <input type="text" name=TxtSoto disabled value="<%=bSoto%>" style="font-family:Arial" size=2 maxlength=4 tabindex=12></td>
	<%else%>
		<td width="16%" nowrap>Số bản <input type="text" name=TxtSoban value="<%=bSoban%>" style="font-family:Arial" size=2 maxlength=4 tabindex=11></td>
		<td width="17%" nowrap>Số tờ <input type="text" name=TxtSoto value="<%=bSoto%>" style="font-family:Arial" size=2 maxlength=4 tabindex=12></td>
	<%end if%>
	<td width="23%" nowrap>
	<%if bBaocao or bComm="add" then%>
		<%if bTTDuyet then%>	
			<label for=C1 accesskey="V">Điểm <u>v</u>ăn bản</label><input name=ChkBC type=checkbox  disabled checked value="ON" id=C1 tabindex=13>
		<%else%>
			<label for=C1 accesskey="V">Điểm <u>v</u>ăn bản</label><input name=ChkBC type=checkbox  checked value="ON" id=C1 tabindex=13>
		<%end if%>
	<%else%>
		<%if bTTDuyet then%>	
			<label for=C1 accesskey="V">Điểm <u>v</u>ăn bản</label><input name=ChkBC type=checkbox disabled value="ON" id=C1 tabindex=13>
		<%else%>
			<label for=C1 accesskey="V">Điểm <u>v</u>ăn bản</label><input name=ChkBC type=checkbox value="ON" id=C1 tabindex=13>
		<%end if%>
	<%end if%>
    </td>
  </tr>
  <tr>
    <td width="14%">Đ/c lưu trữ</td>
    <td width="30%">
	<%if bTTDuyet then%>	
		<select size=1 name=TxtDiachiluutru disabled style='font-family: Arial; height: 23;width:100%; position: relative' tabindex=14>
	<%else%>
		<select size=1 name=TxtDiachiluutru style='font-family: Arial; height: 23;width:100%; position: relative' tabindex=14>
	<%end if%>
	  <%
   		sSQL="Select * from Diachiluutru"
		Set RecDC=server.CreateObject("ADODB.Recordset")
		RecDC.CursorType=3
		RecDC.CacheSize=5
		RecDC.Open sSQL,Conn
		Do While not RecDC.EOF
			if bDisplay then
				if trim(cstr(RecDC("IDLuutru")))=trim(bDiachiluutru) then %>
					<option Selected value=<%=RecDC("IDLuutru")%>><%=RecDC("Ten")%>
				<%else%>
					<option value=<%=RecDC("IDLuutru")%>><%=RecDC("Ten")%>
				<%end if
			else%>
				<%if bComm<>"add" then
					if trim(cstr(RecDC("IDLuutru")))=trim(bDiachiluutru) then %>		<option Selected value=<%=RecDC("IDLuutru")%>><%=RecDC("Ten")%>
					<%else%>
						<option value=<%=RecDC("IDLuutru")%>><%=RecDC("Ten")%>
					<%end if
				else%>
					<option value=<%=RecDC("IDLuutru")%>><%=RecDC("Ten")%>
				<%end if%>
		<%end if
		RecDC.MoveNext
		Loop
		txt="</select>"
		Response.Write(txt)
		RecDC.Close
		Set RecDC=nothing%>
	</td>		
<td width="16%" align=center>Từ khóa</td>
<%if bTTDuyet then%>
	<td width="40%" colspan="2"><input type="text" name=TxtTukhoa disabled value='<%=bTukhoa%>' size=20 maxLength=100 style='font-family:Arial;width:100%' tabindex=15></td>
<%else%>
	<td width="40%" colspan="2"><input type="text" name=TxtTukhoa value='<%=bTukhoa%>' size=20 maxLength=100 style='font-family:Arial;width:100%' tabindex=15></td>
<%end if%>
</tr>
</Table>
<!-- Buttons -->
<table width="100%" border="0" cellspacing="0" style="font-size:12pt; BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" bordercolor="#111111" bgcolor="#BDD5D0">
<tr>
	<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),4)="1" or Session("IsAdmin") then %>
		<td width="16%"><Button name="CmdAdd" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><p><u>T</u>hêm mới</p></Button></td>
	<%else%>
		<td width="16%"><Button name="CmdAdd" disabled style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><p><u>T</u>hêm mới</p></Button></td>
	<%end if%>
	<%if bComm="add" then%>
		<%if bTTDuyet then%>
			<td width="25%"><Button disabled name="CmdNoidungtep" style=" font-family: Arial; height: 25; position: relative; width: 100%" LANGUAGE=javascript onclick="return CmdNoidungtep_onclick()" accesskey="S"><p><u>S</u>oạn nội dung văn thư</p></Button></td>
		<%else%>
			<td width="25%"><Button disabled  name="CmdNoidungtep" style=" font-family: Arial; height: 25; position: relative; width: 100%" LANGUAGE=javascript onclick="return CmdNoidungtep_onclick()" accesskey="S"><p><u>S</u>oạn nội dung văn thư</p></Button></td>
		<%end if%>
	<%else%>
		<%if bTTDuyet then%>
			<td width="25%"><Button disabled  name="CmdNoidungtep" style=" font-family: Arial; height: 25; position: relative; width: 100%" LANGUAGE=javascript onclick="return CmdNoidungtep_onclick()" accesskey="S"><p><u>S</u>oạn nội dung văn thư</p></Button></td>
		<%else%>
			<td width="25%"><Button name="CmdNoidungtep" style=" font-family: Arial; height: 25; position: relative; width: 100%" LANGUAGE=javascript onclick="return CmdNoidungtep_onclick()" accesskey="S"><p><u>S</u>oạn nội dung văn thư</p></Button></td>
		<%end if%>
	<%end if%>
	<%if bComm="add" then%>
		<%if bTTDuyet then%>
			<td width="25%"><Button disabled name="CmdXemNoidung" style="font-family: Arial;width: 100%" LANGUAGE=javascript onclick="return CmdXemNoidung_onclick()" accesskey="X"><p><u>X</u>em nội dung văn thư</p></Button></td>
		<%else%>
			<td width="25%"><Button disabled name="CmdXemNoidung" style="font-family: Arial;width: 100%" LANGUAGE=javascript onclick="return CmdXemNoidung_onclick()" accesskey="X"><p><u>X</u>em nội dung văn thư</p></Button></td>
		<%end if%>
	<%else%>
		<%if bTTDuyet then%>
			<td width="25%"><Button name="CmdXemNoidung" disabled style="font-family: Arial;width: 100%" LANGUAGE=javascript onclick="return CmdXemNoidung_onclick()" accesskey="X"><p><u>X</u>em nội dung văn thư</p></Button></td>
		<%else%>
			<td width="25%"><Button name="CmdXemNoidung" style="font-family: Arial;width: 100%" LANGUAGE=javascript onclick="return CmdXemNoidung_onclick()" accesskey="X"><p><u>X</u>em nội dung văn thư</p></Button></td>
		<%end if%>
	<%end if%>	
	<%if bDisplay then%>
		<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),4)="1" or Session("IsAdmin") then %>
		<td width="16%" >
			<%if bTTDuyet then%>
				<Button name="CmdOK" disabled style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
			<%else%>
				<Button name="CmdOK" style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
			<%end if%>
		<%else%>
		<td width="16%" >
			<Button name="CmdOK" disabled style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
		<%end if%>
	<%else
		if bComm<>"add" then%>
			<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),4)="1" or Session("IsAdmin") then %>
			<td width="16%" >
				<%if bTTDuyet then%>
					<Button name="CmdOK" disabled style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<%else%>
					<Button name="CmdOK" style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<%end if%>
			<%else%>
			<td width="16%" >
				<Button name="CmdOK" disabled style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
			<%end if%>
		<%else%>		
			<td width="16%" >
				<%if bTTDuyet then%>
					<Button name="CmdOK" disabled style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<%else%>
					<Button name="CmdOK" style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<%end if%>
		<%end if
	end if%>
	<td width="18%"><Button name="CmdExit" style="font-family: Arial;width: 100%"   LANGUAGE=javascript onclick="return CmdExit_onclick()" accesskey="Y"><p>Qua<u>y</u> lại</p></Button></td>
  </tr>  
</table>

  <table border="0" cellspacing="1" style="font-size:12pt;BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" width="100%" bgcolor="#BDD5D0" cellpadding="1">
<tr>
	<td width="100%" colspan="5" align="center" bgcolor="#000080">
    <font color="#FFFFFF"><b>Điều hành</b></font></td>
</tr>
<tr>
	<td width="24%" align=center><label for=C2 accesskey="C"><u>C</u>ho phép công bố</label>
	<%	
					if bDisplay then
						if  bReadwrite then
							if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),9)="1" or Session("IsAdmin") then %>
                                <%if bTTDuyet then%>
									<input type=checkbox name=CheckReadwrite Checked language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%else%>
									<input type=checkbox name=CheckReadwrite disabled Checked language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%end if%>
							<%else%>
                                <input type=checkbox name=CheckReadwrite Checked disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
							<%end if
						else
							if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),9)="1" or Session("IsAdmin") then  %>
                                <%if bTTDuyet then%>
									<input type=checkbox name=CheckReadwrite language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%else%>
									<input type=checkbox name=CheckReadwrite disabled language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%end if%>
							<%else%>
                                <input type=checkbox name=CheckReadwrite disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
							<%end if
						end if
					else
						if bComm<>"add" then
							if  bReadwrite then
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),9)="1" or Session("IsAdmin") then  %>
                                    <%if bTTDuyet then%>
										<input type=checkbox name=CheckReadwrite Checked language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
									<%else%>
										<input type=checkbox name=CheckReadwrite disabled Checked language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
									<%end if%>
								<%else%>
                                    <input type=checkbox name=CheckReadwrite Checked disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%end if
							else
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),9)="1" or Session("IsAdmin") then  %>
                                    <%if bTTDuyet then%>
										<input type=checkbox name=CheckReadwrite language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
									<%else%>
										<input type=checkbox name=CheckReadwrite disabled language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
									<%end if%>
								<%else%>
                                    <input type=checkbox name=CheckReadwrite disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%end if
							end if
						else
							if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),9)="1" or Session("IsAdmin") then  %>
								<%if bTTDuyet then%>
	                                <input type=checkbox name=CheckReadwrite language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%else%>
									<input type=checkbox name=CheckReadwrite disabled language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
								<%end if%>
							<%else%>
                                <input type=checkbox name=CheckReadwrite disabled=true  language=javascript onclick='return CheckReadwrite_onclick()' value="ON" id=C2></td>
							<%end if			
						end if
					end if
				%>
				<%  if bDisplay then
						if  bReadwrite then%>
							<td width="20%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
						<%else
							if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
								<%if bTTDuyet then%>
									<td width="20%"><Button name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()' accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%else%>
									<td width="20%"><Button name='CmdDuyet' disabled style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()' accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%end if%>
							<%else%>
								<td width="20%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
							<%end if
						end if
					else
						if bComm<>"add" then
							if  bReadwrite then%>
								<td width="20%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
							<%else
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
									<%if bTTDuyet then%>
										<td width="20%"><Button name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
									<%else%>
										<td width="20%"><Button name='CmdDuyet' disabled style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
									<%end if%>
								<%else%>
									<td width="20%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%end if
							end if
						else
							if bComm="add" then							
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
									<td width="20%"><Button disabled  name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%else%>
									<td width="20%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
								<%end if
							else
								if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),8)="1" or Session("IsAdmin") then  %>
									<%if bTTDuyet then%>
										<td width="20%"><Button name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
									<%else%>
										<td width="20%"><Button name='CmdDuyet' disabled style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>
									<%end if%>
								<%else%>
									<td width="20%"><Button disabled name='CmdDuyet' style='font-family: Arial;width: 100%' LANGUAGE=javascript onclick='return CmdDuyet_onclick()'accesskey="Q"><p><u>Q</u>uy định quyền</p></Button></td>	
								<%end if
							end if
						end if
					end if%>
		<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),9)="1" or Session("IsAdmin") then %>
		<%if bComm="add" then%>
			<%if bTTDuyet then%>
				<td width="20%" ><Button disabled name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
			<%else%>
				<td width="20%" ><Button disabled name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
			<%end if%>
		<%else%>
				<%if bTTDuyet then%>
					<td width="20%" ><Button disabled name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
				<%else%>
					<td width="20%" ><Button name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
				<%end if%>
		<%end if%>
	<%else%>					
		<td width="20%" ><Button disabled name="CmdOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOKDuyet_onclick()" accesskey="D"><p><u>D</u>uyệt nội dung</p></Button></td>
	<%end if%>		
	<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),9)="1" or Session("IsAdmin") then%>
		<%if bTTDuyet then%>
			<td width="20%"><Button  name="CmdNotOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdNotOKDuyet_onclick()" accesskey="H"><p><u>H</u>ủy duyệt nội dung</p></Button></td>
		<%else%>
			<td width="20%"><Button disabled=true name="CmdNotOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdNotOKDuyet_onclick()" accesskey="H"><p><u>H</u>ủy duyệt nội dung</p></Button></td>
		<%end if%>
	<%else%>
		<td width="20%"><Button disabled=true name="CmdNotOKDuyet" style="font-family: Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdNotOKDuyet_onclick()" accesskey="H"><p><u>H</u>ủy duyệt nội dung</p></Button></td>
	<%end if%>
	<%if bDisplay then%>
		<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),5)="1" or Session("IsAdmin") then %>
		<td width="16%" align=right>
			<Button name="CmdEmail" style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
		<%else%>
		<td width="16%" align=right>
			<Button disabled name="CmdEmail" style="font-family: Arial;width:100%" LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
		<%end if%>
	<%else
		if bComm<>"add" then%>
			<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),5)="1" or Session("IsAdmin") then %>
			<td width="16%" align=right>
				<Button name="CmdEmail" style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
			<%else%>
			<td width="16%" align=right>
				<Button disabled name="CmdEmail" style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
			<%end if%>
		<%else%>
			<td width="16%" align=right>
				<Button name="CmdOK" disabled style="font-family: Arial;width:100%"  LANGUAGE=javascript onclick="CmdEmail_onclick()" accesskey="E"><u>E</u>mail</Button>
		<%end if
	end if%>
</tr>
</table>
</Form>
</Body>
</HTML>